import uuid
import hashlib
import os


def generate_machine_ids():
    """生成新的机器标识码"""
    # 生成新的UUID
    dev_device_id = str(uuid.uuid4())

    # 生成新的machineId (64个字符的十六进制)
    machine_id = hashlib.sha256(os.urandom(32)).hexdigest()

    # 生成新的macMachineId (128个字符的十六进制)
    mac_machine_id = hashlib.sha512(os.urandom(64)).hexdigest()

    # 生成新的sqmId
    sqm_id = "{" + str(uuid.uuid4()).upper() + "}"

    return {
        "telemetry.devDeviceId": dev_device_id,
        "telemetry.macMachineId": mac_machine_id,
        "telemetry.machineId": machine_id,
        "telemetry.sqmId": sqm_id,
    }


if __name__ == "__main__":
    new_ids = generate_machine_ids()
    print("新生成的机器标识码：")
    for key, value in new_ids.items():
        print(f"{key}: {value}")
